package com.longge;

/**
 * @program: my-code
 * @description:
 * @author: longge
 * @create: 2021-04-15 02:48
 */
public class OddEvenList {

    public ListNode oddEvenList(ListNode head) {

        if (head==null) return head;

        ListNode odd = head,even = head.next,evenHead = even;
        while (even!=null&&even.next!=null){

            odd.next=even.next;
            odd=odd.next;
            even.next=odd.next;
            even=even.next;
        }
        odd.next=evenHead;
        return head;
    }
}
